//---------------------------------------------------------------------------
/**
 * \class CLineTokenizer
 * \brief This is a tokenizer by line
 * \version 0.1
 *
 * \author Woo-Hyun Kim (woorung@nhncorp.com, woorung@gmail.com)
 * \author http://blog.naver.com/wisereign .
 *
 * \date 2007/10/08
 */
//---------------------------------------------------------------------------
#ifndef CLineTokenizerH
#define CLineTokenizerH

#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <string>

#include "stream/CBlockStream.h"

#define MAX_LINE_LIMIT 10000

using namespace std;
//---------------------------------------------------------------------------
class CLineTokenizer
{
protected:
	CBlockStream *block_stream;

	// if stdin stream, no free
	bool use_file_stream;

	int kpos;
	vector<int> ppos;
	char delim;
	char eol;
	long limit;

	long block;
	long blocks;

public:
        CLineTokenizer();
        virtual ~CLineTokenizer();

        void assign(long block, long blocks); 

        virtual void input(char *file); 
	virtual void input(streambuf *stdbuf);
	virtual void input(stringbuf *strbuf);
        virtual void output(); 

        virtual void format(int kpos); // print all the items
        virtual void format(int kpos, vector<int> &ppos); // only print the selected items
        virtual void filter(char delim, char eol, long limit); 

	int getToken(vector< vector<string> > &token);
};
//---------------------------------------------------------------------------
#endif
